package seqlist.leetcode;

//剑指 Offer 22. 链表中倒数第k个节点
public class Offer_22_getKthFromEnd {
    public ListNode getKthFromEnd(ListNode head, int k) {
        ListNode node1=head;
        ListNode node2=head;
        for (int i = 0; i < k; i++) {
            node1=node1.next;
        }
        while (node1!=null){
            node1=node1.next;
            node2=node2.next;
        }
        return node2;
    }
}
